///////////////////////////////////////////////////////////////
// File: "CHowToPlayState.cpp"
// Author: James Gonzalez(JG)
// Purpose: The HowToPlay for the game
///////////////////////////////////////////////////////////////

#include "CHowToPlayState.h"
#include "CWiimote.h"
#include "../Wrappers/CSGD_DirectInput.h"
#include "CBitmapFontEngine.h"
#include "CMusicManager.h"
#include "CSoundManager.h"
#include "CTransitionScreen.h"
#include "CMainMenuState.h"
#include "..//Wrappers/CSGD_TextureManager.h"
#include "CGame.h"
#include "CLevelSelectState.h"
#include "CGamePlayState.h"
#include "COptionsState.h"

CHowToPlayState::CHowToPlayState(void)
{

	m_bExitToMain = false;
	m_nFontID = -1;
	m_nPageNumber = 1;
	m_nHowToPlayImageImage = -1; 
	

}

CHowToPlayState::~CHowToPlayState(void)
{
}

void CHowToPlayState::Enter()
{
	 
	m_cScreen.LoadScreen("Screens/BS_TallyScreen.xml");
	m_nFontID = CBitmapFontEngine::GetInstance()->LoadFont("BS_TechDemoTitle.xml");
	m_nHowToPlayImageImage = CSGD_TextureManager::GetInstance()->LoadTexture("Resource/BS_HowToPlay.png");
	m_bExitToMain = false;
	m_nPageNumber = 1;
}


void CHowToPlayState::Exit()
{
	m_bExitToMain = false;
}

bool CHowToPlayState::Input(float fElapsedTime)
{
	CWiimote* pWii = CWiimote::GetInstance();
	CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();

// 	if ((pWii->IsButtonJustPressed(WII_LEFT) || pDI->KeyPressed(DIK_LEFT)))
// 	{
// 		--m_nPageNumber;
// 		if (m_nPageNumber < 1)
// 		{
// 			m_nPageNumber = 1;
// 		}
// 	}
// 	else if ((pWii->IsButtonJustPressed(WII_RIGHT) || pDI->KeyPressed(DIK_RIGHT)) )
// 	{
// 		++m_nPageNumber;
// 	}

	
	if ((pWii->IsButtonPressed(WII_HOME) || pDI->KeyPressed(DIK_ESCAPE)) || (pWii->IsButtonPressed(WII_A) || pDI->KeyPressed(DIK_RETURN)))
	{
		CSoundManager::GetInstance()->PlaySoundIndxUnBuffered(SOUND_MENU_SELECT);
		m_bExitToMain = true;
	}	


	return true;
}

void CHowToPlayState::Update(float fElapsedTime)
{

	if (m_bExitToMain)
	{
		CTransitionScreen::GetInstance()->ChangeTo(CMainMenuState::GetInstance()); 
	}

}

void CHowToPlayState::Render()
{

	m_cScreen.RenderScreen();

	//////////////////////////////////////////////////////////////////////////
	//Location Setup
	//////////////////////////////////////////////////////////////////////////
	static CBitmapFontEngine* pBFE = CBitmapFontEngine::GetInstance();
	static CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance();
	static int GREEN = 0xFF00FF00;
	static int YELLOW = 0xFFFFFF00;
	static int RED = 0xFFFF0000;
	//////////////////////////////////////////////////////////////////////////



	//////////////////////////////////////////////////////////////////////////
	//HowToPlay
	//pBFE->RenderString("HOW TO PLAY",m_nFontID,0,GREEN,32,32,0);
	pTM->Draw(m_nHowToPlayImageImage,60,50);

// 	char buff[20];
// 	sprintf_s(buff,"%d",m_nPageNumber);
// 	pBFE->RenderString(buff,m_nFontID,0,GREEN,700,500,0);

	//
	//////////////////////////////////////////////////////////////////////////


} 
